package org.langqiao.experiment.experiment5;
public class Ellipse implements Area{
	private double radius_a;
	private double radius_b;
	public static int flag=0;
	
	public double area() {
		return Math.PI *this.radius_a*this.radius_b;
	}

	public static void main(String[]args){
		Ellipse e=new Ellipse();
		e.select(args);
		if(flag==0){
			if(e.getRadius_a()==e.getRadius_b())
				System.out.print("圆的面积为：");
			else
				System.out.print("椭圆的面积为：");
			System.out.println(e.area());
		}
	}

	public void select(String str[]){
		double a=0,b=0;
		if(str!=null&&str.length==2){
			try{	
			    a=Double.parseDouble(str[0]);
				b=Double.parseDouble(str[1]);
			}catch(NumberFormatException nfe){
				System.out.println("输入不是数字，不能转化为double型数据");
				flag=1;
			}
			this.setRadius_a(a);
			this.setRadius_b(b);
		}
		else{
			System.out.println("没有在运行时输入相应的椭圆或圆的半径的参数！");
			flag=1;
			return;
		}
			
	}
	
	public double getRadius_a() {
		return radius_a;
	}

	public void setRadius_a(double radius_a) {
		this.radius_a = radius_a;
	}

	public double getRadius_b() {
		return radius_b;
	}

	public void setRadius_b(double radius_b) {
		this.radius_b = radius_b;
	}
}
